﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLM
{
    public class AdminFactory:BLMFactory<DOM.Users>
    {
        public bool CheckUser(string uname, string pass)
        {
            return Table.Where(u => u.Username == uname && u.Password == Encryptor.MD5Hash(pass)).SingleOrDefault() != null;
        }

        public bool AddNewUser(DOM.Users u, out int id)
        {
            try
            {
                SaveorUpdate(u);
                id = u.Id;
                return true;
            }
            catch (Exception ex)
            {
                id = 0;
                return false;
            }
        }
    }
}
